Skip to content

ISSDK-1876: Skip x-createOnly defaults in Go NewXxx/NewXxxWithDefaults constructors#177

Open
sagadira wants to merge 1 commit into
CiscoM31:masterfrom
sagadira:ISSDK-1876
Open

ISSDK-1876: Skip x-createOnly defaults in Go NewXxx/NewXxxWithDefaults constructors#177
sagadira wants to merge 1 commit into
CiscoM31:masterfrom
sagadira:ISSDK-1876

Conversation

@sagadira

Copy link
Copy Markdown

Summary

Fixes the Go SDK sending x-createOnly property defaults on resource creation, which the Intersight API rejects (e.g. server_family).

Change

go/model_simple.mustache (+4): the generated NewXxx() / NewXxxWithDefaults() constructors no longer assign default values for properties marked x-createOnly. Previously a x-createOnly property with a default (e.g. ServerFamily = "Unspecified") was initialised in the constructor and then sent in the POST body, causing 400 "Cannot modify the read-only property ...".

This is the Go-SDK analog of the Terraform createOnly -> Computed fix.

Scope

  • Affects the Go generator only.
  • Cisco-specific (x-createOnly is an Intersight extension) — not an upstream candidate.

Ticket: ISSDK-1876

…ts Go constructors

Properties marked x-createOnly must not be injected into the struct by
the generated constructors -- the Intersight API rejects them in POST if
they arrive with a stale default value (e.g. ServerFamily='All' on
server.Profile / server.ProfileTemplate).

Add {{^vendorExtensions.x-createOnly}} guards around the default-value
assignment blocks in both New{{classname}} and New{{classname}}WithDefaults
in model_simple.mustache, mirroring the existing {{^isReadOnly}} pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant